import Vue from "vue";
import Router from "vue-router";
import Login from "./components/login.vue";
import Home from "./components/Home.vue";
import Welcome from "./components/Welcome.vue";
import User from "./components/users/user.vue";
import Rights from "./components/rights/rights.vue";
import students from "./components/users/students.vue";
import Biaobai from "./components/content/biaobai.vue"
import Tucao from "./components/content/tucao.vue"
import Statistics from "./components/statistics/statistics.vue"
import Tiewen from "./components/tiewen/tiewen.vue"
import Board from "./components/Board/Board.vue"
import AddBoard from "./components/Board/AddBoard.vue"
import CardNotice from "./components/Board/CardNotice.vue"
import DepartmentNotice from "./components/Board/DepartmentNotice.vue"
import tiaozao from "./components/tiaozao/tiaozao.vue"
import lost from "./components/goods/lost.vue"
import find from "./components/goods/find.vue"

// const Biaobai = () => import("./components/content/biaobai.vue");
// const Tucao = () => import("./components/content/tucao.vue");
// const Statistics = () => import("./components/statistics/statistics.vue");
// const Tiewen = () => import("./components/tiewen/tiewen.vue");
// const Board = () => import("./components/Board/Board.vue");
// const AddBoard = () => import("./components/Board/AddBoard.vue");
// const CardNotice = () => import("./components/Board/CardNotice.vue");
// const DepartmentNotice = () =>
//   import("./components/Board/DepartmentNotice.vue");
// const tiaozao = () => import("./components/tiaozao/tiaozao.vue");
// const lost = () => import("./components/goods/lost.vue");
// const find = () => import("./components/goods/find.vue");

Vue.use(Router);

const router = new Router({
  mode: "history",
  base: '/dist2',
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: Login,
    },
    {
      path: "/home",
      component: Home,
      redirect: "/welcome",
      children: [
        {
          path: "/welcome",
          component: Welcome,
        },
        {
          path: "/user",
          component: User,
        },
        {
          path: "/students",
          component: students,
        },
        {
          path: "/rights",
          component: Rights,
        },
        {
          path: "/biaobai",
          component: Biaobai,
        },
        {
          path: "/tucao",
          component: Tucao,
        },
        {
          path: "/statistic",
          component: Statistics,
        },
        {
          path: "/tiewen",
          component: Tiewen,
        },

        {
          path: "/board",
          component: Board,
        },
        {
          path: "/AddBoard",
          component: AddBoard,
        },
        {
          path: "/card",
          component: CardNotice,
        },
        {
          path: "/depart",
          component: DepartmentNotice,
        },
        {
          path: "/tiaozao",
          component: tiaozao,
        },
        {
          path: "/lost",
          component: lost,
        },
        {
          path: "/find",
          component: find,
        },
      ],
    },
  ],
});
// 导航守卫 保护有权限的页面
// router.beforeEach(function(to, from, next) {
//   // 如果从login页面来 直接放行
//   if (to.path == "/login") {
//     return next();
//   }
//   const tokenStr = window.sessionStorage.getItem("tokenid");
//   // 如果没有token 即没有登录 则返回到登录页面
//   if (!tokenStr) {
//     return next("/login");
//   }
//   next();
// });
export default router;
